<template>
  <div style="height:100%;width:100%;position:relative;">
      <div class="pagetop" style="border:1px solid #CCC" ref="buttondiv">
          <template>
              <div style="width:100%;">
                  <table style="font-size:12px" class="table1style">
                      <td @click="BtnFresh">
                          <el-button v-has="'PINQUERY'" type="primary" icon="el-icon-search">查询</el-button>
                      </td>
                      <td @click="BtnComReqGroup">
                          <el-button v-has="'PSETSPECIMEN'">设定标本类型</el-button>
                      </td>
                      <td>
                          <el-checkbox v-model="bIsClassifyTip" style="color:red;padding-left:5px"></el-checkbox>
                      </td>
                      <td style="width:95px;white-space: nowrap;color:red">
                          取消归类不提醒
                      </td>
                      <td style="white-space: nowrap;">
                          <el-tag type='warning'>提示:双击右边和中间列表中行可实现归类和取消归类。</el-tag>
                      </td>
                      <td :width="buttonWidth"></td>
                  </table>
              </div>
          </template>
      </div>
      <div class="pagecenter">
          <rm-layout-left splitcolor="#ffffff" :splitwidth="5" :fixsize="350" :minfixsize="100" :maxfixsize="450">
              <template v-slot:fix>
                  <vxe-table show-overflow ref="reqgroup_table" class="mytable-style" height="auto"
                      :loading="bReqGroupLoading" :sort-config="{ trigger: 'cell' }" :keyboard-config="keyConfig"
                      :keyboard-local-config="keyLocalConfig" :data.sync="reqgroup_tabledata" size="mini"
                      show-header-overflow highlight-current-row highlight-hover-row resizable stripe
                      header-align="center" @current-change="ReqGroup_CurrentChangeEvent">
                      <vxe-table-column field="seq" sortable title="序号" width="40" show-overflow header-align="center"
                          align="center"></vxe-table-column>
                      <vxe-table-column sortable field="req_groupcode" title="分单类别代码" width="100">
                      </vxe-table-column>
                      <vxe-table-column sortable field="req_groupname" title="分单类别名称" width="120">
                      </vxe-table-column>
                      <vxe-table-column field="tube_color" sortable title="试管颜色" width="56" show-overflow
                          header-align="center">
                          <template v-slot="{ row }">
                              <div v-bind:style="{ background: $pub.ColorChange(row.tube_color) }"
                                  style="color:transparent">{{ row.tube_color }}</div>
                          </template>
                      </vxe-table-column>
                      <vxe-table-column sortable field="specimen_name" title="默认采集标本" width="120"></vxe-table-column>
                      <vxe-table-column sortable field="hospitalname" title="所属医院" width="120"></vxe-table-column>
                      <vxe-table-column sortable field="specimen_code" title="默认采集标本代码" width="120">
                      </vxe-table-column>
                      <vxe-table-column sortable field="req_groupna" title="类别简称" width="100"></vxe-table-column>
                      <vxe-table-column sortable field="req_groupid" title="分单类别ID" width="120"></vxe-table-column>
                  </vxe-table>
              </template>
              <rm-layout-right splitcolor="#ffffff" :splitwidth="5" :fixsize="520" :minfixsize="400"
                  :maxfixsize="580">
                  <rm-layout-top splitcolor="#ffffff" :fixsize="53" :canDrag="false">
                      <template v-slot:fix>
                          <div ref="buttondiv1">
                              <table style="font-size:14px;">
                                  <tr>
                                      <td style="color:RoyalBlue;font-weight:700">
                                          当前分单({{ message }}) {{ reqGroupHosp }}
                                      </td>
                                  </tr>
                              </table>
                              <table style="font-size:14px;">
                                  <tr>
                                      <td :width="buttonWidth1"></td>
                                      <!-- <td style="align:right;" @click="BtnRowTop">
                                          <el-button>首位</el-button>
                                      </td>
                                      <td style="align:right;" @click="BtnRowUp">
                                          <el-button>上移</el-button>
                                      </td>
                                      <td style="align:right;" @click="BtnRowDown">
                                          <el-button>下移</el-button>
                                      </td>
                                      <td style="align:right;" @click="BtnRowUpBottom">
                                          <el-button>末位</el-button>
                                      </td> -->
                                      <td style="align:right;" @click="BtnBatchReqItemGroups">
                                          <el-button>批量自动编号归类</el-button>
                                      </td>
                                      <td style="align:right;" @click="BtnSaveSeq">
                                          <el-button>保存序号、自动编号归类</el-button>
                                      </td>
                                  </tr>
                              </table>
                          </div>
                      </template>
                      <vxe-table show-overflow ref="match_table" class="mytable-style" height="auto"
                          :loading="bReqGroupDetailLoading" :sort-config="{ trigger: 'cell' }"
                          :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig"
                          :data.sync="match_tabledata" border size="mini" show-header-overflow highlight-current-row
                          highlight-hover-row resizable stripe header-align="center" @cell-dblclick="BtnDblNoMatch"
                          @current-change="Match_CurrentChangeEvent"
                          :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false }"
                          :row-class-name="rowClassName">
                          <vxe-table-column sortable field="seq" title="序号" width="60" align="center" :edit-render="{
                              name: 'input',
                              autoselect: true,
                          }"></vxe-table-column>
                          <vxe-table-column sortable field="req_itemname" title="项目名称" width="300"></vxe-table-column>
                          <vxe-table-column sortable field="req_itemcode" title="项目代码" width="100"></vxe-table-column>
                          <vxe-table-column sortable field="item_price" title="单价" width="80" header-align="center"
                              align="right"></vxe-table-column>
                          <vxe-table-column sortable field="specimen_name" title="默认标本" width="100">
                          </vxe-table-column>
                          <vxe-table-column sortable field="singletube" key="singletube" title="单独采样" width="80"
                              align="center">
                              <template v-slot="{ row }">
                                  <el-checkbox v-model="row.singletube" true-label="1" false-label="0"
                                      @change="Setsingletube($event)"></el-checkbox>
                              </template>
                          </vxe-table-column>
                          <vxe-table-column field="reqitemgroups" title="自动编号归类" width="120"
                              :edit-render="{ name: 'input', autoselect: true }">
                          </vxe-table-column>
                          <vxe-table-column sortable field="inputcode" title="拼音码" width="150"></vxe-table-column>
                          <vxe-table-column sortable field="perform_deptname" title="执行科室" width="150">
                          </vxe-table-column>
                          <vxe-table-column sortable field="req_groupna" title="分单类别" width="120"></vxe-table-column>
                          <vxe-table-column sortable field="disabled" title="在用" width="40" align="center">
                          </vxe-table-column>
                      </vxe-table>
                  </rm-layout-top>
                  <template v-slot:fix>
                      <rm-layout-top splitcolor="#ffffff" :fixsize="53" :canDrag="false">
                          <template v-slot:fix>
                              <table style="font-size:14px">
                                  <tr>
                                      <td style="white-space: nowrap;color:red;padding:3px 0px 0px 0px">
                                          {{ reqItemHosp }}
                                      </td>
                                  </tr>
                              </table>
                              <table ref="buttondiv2" style="font-size:14px">
                                  <tr>
                                      <td :width="buttonWidth1"></td>
                                      <td>
                                          <el-input v-model="fuzzyquery" placeholder="输入项目名称|项目代码|拼音码 回车"
                                              @keyup.enter.native="NoMatchReqItem" style="width:300px"
                                              ref="reqiteminput" @focus="SelectAll()"></el-input>
                                      </td>
                                      <td>
                                          <el-button type="primary" @click.native="NoMatchReqItem"
                                              icon="el-icon-search">查询</el-button>
                                      </td>
                                  </tr>
                              </table>
                          </template>
                          <vxe-table show-overflow ref="nomatch_table" class="mytable-style" height="auto"
                              :loading="bNoMatchReqItemLoading" :sort-config="{ trigger: 'cell' }"
                              :keyboard-config="keyConfig" :keyboard-local-config="keyLocalConfig"
                              :data.sync="nomatch_tabledata" border size="mini" show-header-overflow
                              highlight-current-row highlight-hover-row resizable stripe header-align="center"
                              @cell-dblclick="Match" @current-change="NoMatch_CurrentChangeEvent">
                              <vxe-table-column sortable field="seq" title="序号" width="60" align="center">
                              </vxe-table-column>
                              <vxe-table-column sortable field="req_itemname" title="项目名称" width="160">
                              </vxe-table-column>
                              <vxe-table-column sortable field="itemclasscode" title="项目归类" width="100">
                              </vxe-table-column>
                              <vxe-table-column sortable field="hospitalname" title="所属医院" width="200">
                              </vxe-table-column>
                              <vxe-table-column sortable field="specimen_name" title="默认标本" width="100">
                              </vxe-table-column>
                              <vxe-table-column sortable field="req_itemcode" title="项目代码" width="100">
                              </vxe-table-column>
                              <vxe-table-column sortable field="item_price" title="单价" width="80"></vxe-table-column>

                              <vxe-table-column sortable field="singletube" key="singletube" title="单独采样" width="80"
                                  align="center">
                                  <template v-slot="{ row }">
                                      <el-checkbox v-model="row.singletube" true-label="1" false-label="0" readonly>
                                      </el-checkbox>
                                  </template>
                              </vxe-table-column>
                              <vxe-table-column field="reqitemgroups" title="自动编号归类" width="120">
                              </vxe-table-column>
                              <vxe-table-column sortable field="req_groupna" title="分单类别" width="150">
                              </vxe-table-column>
                              <vxe-table-column sortable field="inputcode" title="拼音码" width="250"></vxe-table-column>
                              <vxe-table-column field="perform_deptname" title="执行科室" width="150"></vxe-table-column>
                          </vxe-table>
                      </rm-layout-top>
                  </template>
              </rm-layout-right>
          </rm-layout-left>
      </div>
      <div>
          <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" style="padding:5px"
              :title="dlgTitleNoTips" :visible.sync="bCancelMatchDlg" width="500px">
              <span>是否要从当前归类中剔除申请项目?</span>
              <span slot="footer" class="dialog-footer">
                  <el-checkbox v-model="bIsClassifyTip" style="color:red"></el-checkbox><span
                      style="padding-right:5px;color:red;width:150px;white-space: nowrap;font-size:12px;">
                      本次不再提醒</span>
                  <el-button @click="CancelMatch1">确 定</el-button>
                  <el-button @click="bCancelMatchDlg = false" :autofocus="true">取 消</el-button>
              </span>
          </el-dialog>
      </div>
      <div>
          <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" style="padding:5px"
              :title="dlgTitleComReqGroup" :visible.sync="bComReqGroupDlg" width="500px">
              <span>是否批次设定当前分单类别下所有项目的默认标本类型?</span>
              <span slot="footer" class="dialog-footer">
                  <el-button @click="SaveComReqGroup()">确 定</el-button>
                  <el-button @click="bComReqGroupDlg = false" :autofocus="true">取 消</el-button>
              </span>
          </el-dialog>
      </div>
      <div>
          <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" style="padding:5px"
              :title="dlgTitleComReqGroup" :visible.sync="bShowRIg" width="300px">
              <span>请输入批量自动编号归类的名称：</span>
              <span>
                  <el-input v-model="allrig" ref="allrigref" style="width:160px" placeholder="">
                  </el-input>
              </span>
              <span slot="footer" class="dialog-footer">
                  <el-button @click="Saveallrig()" type="primary">确 定</el-button>
                  <el-button @click="bShowRIg = false" :autofocus="true">取 消</el-button>
              </span>
          </el-dialog>
      </div>
  </div>
</template>

<script>
export default {
  name: "MNG242",
  data() {
      return {
          fuzzyquery: "",
          allrig: "", //自动编号归类
          bReqGroupLoading: false,
          bReqGroupDetailLoading: false,
          bNoMatchReqItemLoading: false,
          bAfterfirstloading: true,
          bAfterfirstloading1: true,
          bAfterfirstloading2: true,
          bQueryAll: true,
          bIsClassifyTip: false,
          bCancelMatchDlg: false,
          bComReqGroupDlg: false,
          tempindex: 0,
          matchCurrRowIndex: 0,
          noMatchCurrRowIndex: 0,
          AllData: [],
          tempData: [],
          reqGroupCurrRow: [],
          matchCurrRow: [],
          noMatchCurrRow: [],
          reqgroup_tabledata: [],
          match_tabledata: [],
          nomatch_tabledata: [],
          nomatch_tabledata1: [],
          hospOption: [],
          reqGroupHosp: "",
          reqItemHosp: "",
          itemseq: "",
          singletube: "",
          seq: "",
          saveseq: "",
          req_itemcode: "",
          req_itemcode_nomatch: "",
          req_groupid: "",
          hospcode: "",
          message: "",
          buttonWidth: "",
          buttonWidth1: "",
          buttonWidth2: "",
          dlgTitleNoTips: "",
          dlgTitleComReqGroup: "",
          initHosp: "",
          keyConfig: {
              isDel: true,
              isTab: true,
              isEdit: true,
          },
          keyLocalConfig: {
              isArrow: true,
          },
          bShowRIg: false,
      };
  },
  created() {
      this.QueryHosp();
      this.QueryReqGroup();
      this.NoMatchReqItem();
      this.$ddldata.IsAreaModeFun().then((r) => { }); //防止刷新页面导致IsAreaMode被清掉
  },
  mounted() { },
  updated() {
      this.getButtonWidth();
  },
  methods: {
      //添加对禁用的申请项目标红显示。
      rowClassName({ row, rowIndex }) {
          if (row.disabled == "禁用") {
              return "row--del";
          }
      },
      //添加自动编号归类保存与批量保存，修复序号排序问题
      Saveallrig() {
          this.match_tabledata.forEach((e) => {
              e.reqitemgroups = this.allrig;
          });
          this.bShowRIg = false;
      },
      BtnBatchReqItemGroups() {
          this.allrig = "";
          this.bShowRIg = true;
          setTimeout(() => {
              this.$refs.allrigref.focus();
          }, 300);
      },
      ReqGroupComCallFun() {
          this.$nextTick(() => {
              let currentrow = this.$refs.reqgroup_table.getData(this.tempindex);
              if (currentrow) {
                  this.bAfterfirstloading = false;
                  this.$refs.reqgroup_table.setCurrentRow(currentrow);
                  this.ReqGroup_CurrentRowEvent(currentrow, this.tempindex);
              }
          });
      },
      MatchComCallFun() {
          this.$nextTick(() => {
              let currentrow = this.$refs.match_table.getData(0);
              if (currentrow) {
                  this.bAfterfirstloading1 = false;
                  this.$nextTick(() => {
                      this.$refs.match_table.setCurrentRow(currentrow);
                      this.req_itemcode = currentrow.req_itemcode;
                      this.matchCurrRow = currentrow;
                  });
              }
          });
      },
      NoMatchComCallFun() {
          this.$nextTick(() => {
              let currentrow = this.$refs.nomatch_table.getData(0);
              if (currentrow) {
                  this.bAfterfirstloading2 = false;
                  this.$nextTick(() => {
                      this.$refs.nomatch_table.setCurrentRow(currentrow);
                      this.req_itemcode_nomatch = currentrow.req_itemcode;
                      this.noMatchCurrRow = currentrow;
                      if (this.$ddldata.IsAreaMode) {
                          this.reqItemHosp = "仅显示(" + this.initHosp + ")的项目";
                      } else {
                          this.reqGroupHosp = "";
                      }
                  });
              } else {
                  if (this.$ddldata.IsAreaMode) {
                      this.reqItemHosp = "当前分单类别下无(" + this.initHosp + ")的项目。";
                  } else {
                      this.reqGroupHosp = "";
                  }
              }
          });
      },
      //ReqGroup行选中事件
      ReqGroup_CurrentChangeEvent({ row, $rowIndex }) {
          this.reqGroupCurrRow = row;
          this.ReqGroup_CurrentRowEvent(row, $rowIndex);
      },
      ReqGroup_CurrentRowEvent(row, $rowIndex) {
          this.tempindex = $rowIndex;
          this.req_groupid = row.req_groupid;
          this.hospcode = row.hospcode;
          this.initHosp = row.hospitalname;
          console.log("this.initHop", this.initHosp);
          this.message = row.req_groupna;
          if (this.$ddldata.IsAreaMode) {
              this.reqGroupHosp = " 当前医院(" + this.initHosp + ")";
          } else {
              this.reqGroupHosp = "";
          }
          this.QueryGroupDetail();
          this.$refs.reqiteminput.focus();
      },
      SelectAll() {
          this.$refs.reqiteminput.select();
      },
      //Match行选中事件
      Match_CurrentChangeEvent({ row, $rowIndex }) {
          this.matchCurrRow = row;
          this.matchCurrRowIndex = $rowIndex;
          this.req_itemcode = row.req_itemcode;
          this.itemseq = row.seq;
          this.singletube = row.singletube;
      },
      //NoMatch_行选中事件
      NoMatch_CurrentChangeEvent({ row, $rowIndex }) {
          this.noMatchCurrRow = row;
          // this.reqItemHosp = row.hospitalname;
          this.noMatchCurrRowIndex = $rowIndex;
          this.req_itemcode_nomatch = row.req_itemcode;
          this.seq = row.seq;
          this.singletube = row.singletube;
      },
      //获取按钮宽度
      getButtonWidth() {
          if (this.$refs.buttondiv) {
              this.buttonWidth = this.$refs.buttondiv.offsetWidth + "px";
              this.buttonWidth1 = this.$refs.buttondiv1.offsetWidth + "px";
              this.buttonWidth2 = this.$refs.buttondiv2.offsetWidth + "px";
          }
      },
      //查询分单类别
      QueryReqGroup() {
          this.bReqGroupLoading = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG242",
                  method: "post",
                  data: {
                      action: "queryreqgroup",
                  },
              })
              .then((response) => {
                  this.reqgroup_tabledata = response;
                  this.bReqGroupLoading = false;
                  this.bAfterfirstloading = true;
                  this.ReqGroupComCallFun();
              })
              .catch((e) => {
                  console.log("error", e);
                  this.bReqGroupLoading = false;
              });
      },
      //查询当前项目
      QueryGroupDetail() {
          this.bReqGroupDetailLoading = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG242",
                  method: "post",
                  data: {
                      action: "querygroupdetail",
                      req_groupid: this.req_groupid,
                      hospcode: this.hospcode,
                  },
              })
              .then((response) => {
                  this.match_tabledata = response;
                  this.bReqGroupDetailLoading = false;
                  this.bAfterfirstloading1 = true;
                  this.MatchComCallFun();
                  this.GetButtonRow_Match();
              })
              .catch((e) => {
                  console.log("error", e);
                  this.bReqGroupDetailLoading = false;
              });
      },
      //查询未对照的项目
      NoMatchReqItem() {
          this.bNoMatchReqItemLoading = true;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG242",
                  method: "post",
                  data: {
                      action: "nomatchreqitem",
                      req_groupid: this.req_groupid,
                      hospcode: this.hospcode,
                      fuzzyquery: this.fuzzyquery,
                  },
              })
              .then((response) => {
                  this.nomatch_tabledata = response;
                  this.nomatch_tabledata1 = JSON.parse(JSON.stringify(response));
                  this.bNoMatchReqItemLoading = false;
                  this.bAfterfirstloading2 = true;
                  this.NoMatchComCallFun();
              })
              .catch((e) => {
                  console.log("error", e);
                  this.bNoMatchReqItemLoading = false;
              });
      },
      NoMatchCom() {
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG242",
                  method: "post",
                  data: {
                      action: "nomatchreqitem",
                      req_groupid: this.req_groupid,
                  },
              })
              .then((response) => {
                  this.nomatch_tabledata = response;
              })
              .catch((e) => { });
      },
      //对照
      Match({ row }) {
          let loginutype = this.$tool.getSession(this.$tool.loginutype);
          //console.log("this.$ddldata.IsAreaMode ", this.$ddldata.IsAreaMode);
          var update_specimen = "";
          if (row.specimen_code != "" && row.specimen_code != null) {
              update_specimen = row.specimen_code;
          } else {
              update_specimen = this.reqGroupCurrRow.specimen_code;
          }
          if (loginutype != "G" && this.hospcode == "All" && this.$ddldata.IsAreaMode) {
              //弹窗提示
              this.$alert("您不是管理员，不能对照医院代码为All的项目！", "提示", {
                  confirmButtonText: "确定",
              });
              return false;
          } else {
              this.saveseq = (this.$refs.match_table.afterFullData.length + 1) * 10;
              this.$tool
                  .request({
                      url: "MNG/MNG2/MNG242",
                      method: "post",
                      data: {
                          action: "match",
                          req_groupid: this.req_groupid,
                          req_itemcode: row.req_itemcode,
                          seq: this.saveseq,
                          update_specimen: update_specimen,
                      },
                  })
                  .then((response) => {
                      if (response.errcode != "1") {
                          this.$alert("保存失败！" + response.errmsg, "warning");
                      } else {
                          this.$table.DelRecordSelect(this.$refs.nomatch_table, -1, this);
                          this.QueryGroupDetail();
                      }
                  })
                  .catch((e) => {
                      this.$alert(e, "出错");
                      // this.bNoMatchReqItemLoading = false;
                  });
          }
      },
      //取消对照
      CancelMatch1(row) {
          let loginutype = this.$tool.getSession(this.$tool.loginutype);
          if (loginutype != "G" && this.hospcode == "All" && this.$ddldata.IsAreaMode) {
              //弹窗提示
              this.$alert("您不是管理员，不能取消对照医院代码为All的项目！", "提示", {
                  confirmButtonText: "确定",
              });
              return false;
          } else {

              this.$tool
                  .request({
                      url: "MNG/MNG2/MNG242",
                      method: "post",
                      data: {
                          action: "cancelmatch",
                          req_groupid: this.req_groupid,
                          req_itemcode: row.req_itemcode,
                      },
                  })
                  .then((response) => {
                      if (response.errcode != "1") {
                          this.$alert("保存失败！" + response.errmsg, "warning");
                      } else {
                          this.$table.DelRecordSelect(this.$refs.match_table, -1, this);
                          this.bCancelMatchDlg = false;
                          this.NoMatchReqItem();
                      }
                  })
                  .catch((e) => {
                      this.$alert(e, "error");
                  });
          }
      },
      //取消归类不提醒弹窗
      // NoTips() {
      //     this.dlgTitleNoTips = "取消提醒提示";
      //     this.bCancelMatchDlg = true;
      // },
      //刷新分单类别
      BtnFresh() {
          this.QueryReqGroup();
          this.NoMatchReqItem(); 
      },
      //设定标本类型弹窗
      BtnComReqGroup() {
          this.dlgTitleComReqGroup = "设定标本类型";
          this.bComReqGroupDlg = true;
      },
      //设定标本类型保存
      SaveComReqGroup() {
          var specimen = this.reqGroupCurrRow.specimen_code;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG242",
                  method: "post",
                  data: {
                      action: "setspecimen",
                      req_groupid: this.req_groupid,
                  },
              })
              .then((response) => {
                  if (response.errcode != "1") {
                      this.$message({
                          message: "保存失败！" + response.errmsg,
                          type: "warning",
                      });
                  } else {
                      this.bComReqGroupDlg = false;
                      this.QueryReqGroup();
                  }
              })
              .catch((e) => { });
      },
      //取消归类不提醒
      BtnDblNoMatch({ row, rowIndex }) {
          if (this.bIsClassifyTip) {
              this.CancelMatch1(row, rowIndex);
          } else {
              //this.NoTips();
              this.$confirm("是否要从当前归类中剔除申请项目？", "取消提醒", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
              })
                  .then(() => {
                      this.CancelMatch1(row, rowIndex);
                  })
                  .catch(() => { });
          }
      },
      //上移
      BtnRowUp() {
          if (this.matchCurrRowIndex > 0) {
              let upData = this.$refs.match_table.tableData[this.matchCurrRowIndex - 1];
              let currentrow = this.$refs.match_table.tableData[this.matchCurrRowIndex];
              this.$refs.match_table.tableData.splice(this.matchCurrRowIndex - 1, 1);
              this.$refs.match_table.tableData.splice(this.matchCurrRowIndex, 0, upData);
              this.matchCurrRowIndex = this.matchCurrRowIndex - 1;
              this.$nextTick(() => {
                  this.$refs.match_table.setCurrentRow(currentrow);
              });
          }
      },
      //下移
      BtnRowDown() {
          if (this.matchCurrRowIndex !== this.$refs.match_table.tableData.length - 1) {
              let downData = this.$refs.match_table.tableData[this.matchCurrRowIndex + 1];
              let currentrow = this.$refs.match_table.tableData[this.matchCurrRowIndex];
              this.$refs.match_table.tableData.splice(this.matchCurrRowIndex + 1, 1);
              this.$refs.match_table.tableData.splice(this.matchCurrRowIndex, 0, downData);
              this.matchCurrRowIndex = this.matchCurrRowIndex + 1;
              this.$nextTick(() => {
                  this.$refs.match_table.setCurrentRow(currentrow);
              });
          }
      },
      //首位
      BtnRowTop() {
          if (this.matchCurrRowIndex > 0) {
              let topData = this.$refs.match_table.tableData[this.matchCurrRowIndex];
              this.$refs.match_table.tableData.splice(this.matchCurrRowIndex, 1);
              this.$refs.match_table.tableData.splice(0, 0, topData);
              this.matchCurrRowIndex = 0;
              this.$nextTick(() => {
                  this.$refs.match_table.setCurrentRow(topData);
              });
              this.GetTopRow_Match();
          }
      },
      //末位
      BtnRowUpBottom() {
          if (this.matchCurrRowIndex != this.$refs.match_table.tableData.length - 1) {
              let bottomData = this.$refs.match_table.tableData[this.matchCurrRowIndex];
              this.$refs.match_table.tableData.splice(this.matchCurrRowIndex, 1);
              this.$refs.match_table.tableData.splice(this.$refs.match_table.tableData.length, 0, bottomData);
              this.matchCurrRowIndex = this.$refs.match_table.tableData.length - 1;
              this.$nextTick(() => {
                  this.$refs.match_table.setCurrentRow(bottomData);
              });
              this.GetButtonRow_Match();
          }
      },
      //保存序号
      BtnSaveSeq() {
          let tempseq = 0;
          let temptabledata = [];
          // let tpdata = {};
          let nowdata = this.$refs.match_table.getTableData().fullData;
          nowdata.sort((a, b) => {
              return a.seq - b.seq;
          });
          for (let i = 0, len = nowdata.length; i < len; i++) {
              let tpdata = {};
              tempseq = (i + 1) * 10;
              tpdata.seq = tempseq;
              tpdata.reqitemgroups = nowdata[i].reqitemgroups;
              tpdata.req_itemcode = nowdata[i].req_itemcode;
              // if (tempseq !== nowdata[i].seq) {
              //     nowdata[i].seq = tempseq;
              // }
              temptabledata.push(tpdata);
          }
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG242",
                  method: "post",
                  data: {
                      action: "saveseq",
                      reqitem: temptabledata,
                  },
              })
              .then((response) => {
                  if (response.errcode == "1") {
                      this.$message({
                          message: "操作成功！",
                          type: "success",
                      });
                      this.firstquery = true;
                  } else {
                      this.$message({
                          message: "保存失败！" + response.errmsg,
                          type: "warning",
                      });
                  }
                  this.QueryGroupDetail();
              });
      },
      //首行滚动选中_Match
      GetTopRow_Match() {
          this.$nextTick(() => {
              let toTop = this.$refs.match_table.tableData[0];
              this.$refs.match_table.scrollToRow(toTop);
          });
      },
      //尾行滚动选中_Match
      GetButtonRow_Match() {
          this.$nextTick(() => {
              var alldataLen = this.$refs.match_table.tableData.length;
              console.log("alldataLen", alldataLen);
              let toButton = this.$refs.match_table.tableData[alldataLen - 1];
              this.$refs.match_table.scrollToRow(toButton);
          });
      },
      //首行滚动选中_NoMatch
      GetTopRow_NoMatch() {
          this.$nextTick(() => {
              let toTop = this.$refs.nomatch_table.tableData[0];
              this.$refs.match_table.scrollToRow(toTop);
          });
      },
      //尾行滚动选中_NoMatch
      GetButtonRow_NoMatch() {
          this.$nextTick(() => {
              var alldataLen = this.$refs.nomatch_table.tableData.length;
              let toButton = this.$refs.match_table.tableData[alldataLen - 1];
              this.$refs.match_table.scrollToRow(toButton);
          });
      },
      //单独采样_Match
      Setsingletube(e) {
          if (e == "1") {
              this.singletube = 1;
          } else {
              this.singletube = 0;
          }
          let setsingletube = this.singletube;
          this.$tool
              .request({
                  url: "MNG/MNG2/MNG242",
                  method: "post",
                  data: {
                      action: "setsingletube",
                      req_itemcode: this.req_itemcode,
                      singletube: this.singletube,
                  },
              })
              .then((response) => {
                  if (response.errcode != "1") {
                      this.$message({
                          message: "保存失败！" + response.errmsg,
                          type: "warning",
                      });
                  }
              })
              .catch((e) => { });
      },
      async QueryHosp() {
          try {
              const res = await this.$tool.request({
                  url: "MNG/MNG2/MNG242",
                  method: "post",
                  data: {
                      action: "queryhosp",
                  },
              });
              this.hospOption = res;
          } catch (e) { }
      },
  },
};
</script>

<style scoped>
.pagetop {
  width: 100%;
  height: 35px;
  display: -webkit-box;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
}

.pagecenter {
  position: absolute;
  top: 37px;
  width: 100%;
  left: 0;
  right: 0;
  bottom: 3px;
  overflow: auto;
}

.table1style tr td {
  padding: 0px 2px 0px 5px;
}

::v-deep .middle-center tr td div .el-input__inner {
  border: 1px solid rgba(255, 254, 254, 0) !important;
  background-color: rgba(255, 254, 254, 0) !important;
}

::v-deep .mytable-style.vxe-table .vxe-body--column.col-orange {
  background-color: #ccc;
}

::v-deep .vxe-table .vxe-body--row.row--del {
  color: #f56c6c;
  text-decoration: line-through;
  background: rgb(241, 240, 240);
}
</style>

